<%--
  Created by IntelliJ IDEA.
  User: 22936
  Date: 2022/4/29
  Time: 10:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>MyShare主页面</title>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link rel="shortcut icon" type="image/x-icon" href="../../static/img/book.ico">
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .div_page {
            margin:0 auto;
            width: 100%;
            height: 40px;
        }

        .ul_page {
            list-style: none;
            height: 40px;
            line-height: 40px;
            text-align: center;
        }

        .li_page {
            float: left;
            width: 40px;
            height: 40px;
            display: inline-block;
            background-color: ghostwhite;
            border: darkgray solid 2px;
            border-radius: 8px;
            text-align: center;
        }

        .a_page {
            text-decoration: none;
            display: inline-block;
            width: 36px;
            height: 36px;
            border-color: darkgray;
            text-align: center;
        }
    </style>
</head>
</head>
<body>
<jsp:include page="top.jsp"></jsp:include>
<div style="margin-bottom:5%">
</div>
<div class="container">

    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1>
                    <small>书籍列表 —— 显示所有书籍</small>
                </h1>
                <%--                <p><a>${sessionScope.get("uName")}</a>,欢迎！<a href="${pageContext.request.contextPath}/user/exit">注销</a>--%>
                </p>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-4 column">
            <a class="btn btn-primary" href="${pageContext.request.contextPath}/book/allBook">显示全部书籍</a>
            <c:if test="${sessionScope.get('uType')==true}">
                <a class="btn btn-primary" href="${pageContext.request.contextPath}/book/toAddBook">新增书籍</a>
            </c:if>
        </div>
        <div class="col-md-4 column"></div>
        <div class="col-md-4 column">
            <form class="form-inline" action="${pageContext.request.contextPath}/book/queryBook" method="get"
                  style="float: right">
                <input name="bookName" class="form-control" type="text" placeholder="请输入要查询的书籍名称">
                <input type="submit" value="查询" class="btn btn-primary">
            </form>
        </div>
    </div>

    <div class="row clearfix">
        <div class="col-md-12 column">
            <table class="table table-hover table-striped">
                <thead>
                <tr>
                    <th>书籍编号</th>
                    <th>书籍名字</th>
                    <th>书籍数量</th>
                    <th>书籍详情</th>
                    <th>文件类型</th>
                    <th>操作</th>
                    <%--<th>序号</th>
                    <th>名字</th>
                    <th>概述</th>
                    <th>作用</th>
                    <th>操作</th>--%>
                </tr>
                </thead>

                <tbody>
                <c:forEach var="book" items="${requestScope.get('list')}">
                    <c:if test="${book!=null}">
                        <tr>
                            <td>${book.getBookID()}</td>
                            <td>${book.getBookName()}</td>
                            <td>${book.getBookCounts()}</td>
                            <td>${book.getDetail()}</td>
                            <td>${book.getSuffix()}</td>
                            <td>
                                <c:if test="${sessionScope.get('uType')==true}">
                                    <a href="${pageContext.request.contextPath}/book/toUpdateBook?id=${book.getBookID()}">更改</a>
                                    |
                                    <a href="${pageContext.request.contextPath}/book/delete?id=${book.getBookID()}">删除</a>
                                </c:if>
                                |
                                <a href="${pageContext.request.contextPath}/file/down?name=${book.getBookName()}&fileSuffix=${book.getSuffix()}">下载</a>
                            </td>
                        </tr>
                    </c:if>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>
    <div class="div_page" style="margin-top:20px ">
        <h4>选页</h4>
        <ul class="ul_page">
            <c:if test="${requestScope.get('AllPage')!=0}">
                <c:forEach var="i" begin="1" end="${requestScope.AllPage}" step="1">
                    <li class="li_page"><a class="a_page" href="${pageContext.request.contextPath}/book/page?pageNum=${i}&AllPage=${requestScope.get('AllPage')}">${i}</a></li>
                </c:forEach>
            </c:if>
        </ul>
    </div>
</div>
</body>
</html>
